//
//  UIButton+Extension.swift
//  SinaWeiBo
//
//  Created by mac on 16/12/5.
//  Copyright © 2016年 heima. All rights reserved.
//

import UIKit

extension UIButton{
//  扩展按钮的一个便利构造函数
convenience init(imageName: String? = nil, backgroundImageName: String? = nil, title: String? = nil, titleColor: UIColor? = nil, fontSize: CGFloat? = nil) {
    self.init()
    if let imgName = imageName {
        self.setImage(UIImage(named: imgName), for: .normal)
    }
    if let bgImageName = backgroundImageName {
        self.setBackgroundImage(UIImage(named: bgImageName), for: .normal)
    }
    if let myTitle = title {
        self.setTitle(myTitle, for: .normal)
    }
    if let myTitleColor = titleColor {
        self.setTitleColor(myTitleColor, for: .normal)
    }
    if let myFontSize = fontSize {
        self.titleLabel?.font = UIFont.systemFont(ofSize: myFontSize)
    }
    
    
}
}
